//package com.community.charge.controller;
//
//import java.util.List;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.PutMapping;
//import org.springframework.web.bind.annotation.DeleteMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import com.community.common.annotation.Log;
//import com.community.common.core.controller.BaseController;
//import com.community.common.core.domain.AjaxResult;
//import com.community.common.enums.BusinessType;
//import com.community.charge.domain.MeterReadingRecords;
//import com.community.charge.service.IMeterReadingRecordsService;
//import com.community.common.utils.poi.ExcelUtil;
//import com.community.common.core.page.TableDataInfo;
//
///**
// * 抄表账单Controller
// *
// * @author ruoyi
// * @date 2025-10-29
// */
//@RestController
//@RequestMapping("/charge/records")
//public class MeterReadingRecordsController extends BaseController {
//    @Autowired
//    private IMeterReadingRecordsService meterReadingRecordsService;
//
//    /**
//     * 查询抄表账单列表
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:list')")
//    @GetMapping("/list")
//    public TableDataInfo list(MeterReadingRecords meterReadingRecords)
//    {
//        startPage();
//        List<MeterReadingRecords> list = meterReadingRecordsService.selectMeterReadingRecordsList(meterReadingRecords);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出抄表账单列表
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:export')")
//    @Log(title = "抄表账单", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, MeterReadingRecords meterReadingRecords)
//    {
//        List<MeterReadingRecords> list = meterReadingRecordsService.selectMeterReadingRecordsList(meterReadingRecords);
//        ExcelUtil<MeterReadingRecords> util = new ExcelUtil<MeterReadingRecords>(MeterReadingRecords.class);
//        util.exportExcel(response, list, "抄表账单数据");
//    }
//
//    /**
//     * 获取抄表账单详细信息
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:query')")
//    @GetMapping(value = "/{communityId}")
//    public AjaxResult getInfo(@PathVariable("communityId") Long communityId)
//    {
//        return success(meterReadingRecordsService.selectMeterReadingRecordsByCommunityId(communityId));
//    }
//
//    /**
//     * 新增抄表账单
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:add')")
//    @Log(title = "抄表账单", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody MeterReadingRecords meterReadingRecords)
//    {
//        return toAjax(meterReadingRecordsService.insertMeterReadingRecords(meterReadingRecords));
//    }
//
//    /**
//     * 修改抄表账单
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:edit')")
//    @Log(title = "抄表账单", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody MeterReadingRecords meterReadingRecords)
//    {
//        return toAjax(meterReadingRecordsService.updateMeterReadingRecords(meterReadingRecords));
//    }
//
//    /**
//     * 删除抄表账单
//     */
//    @PreAuthorize("@ss.hasPermi('charge:records:remove')")
//    @Log(title = "抄表账单", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{communityIds}")
//    public AjaxResult remove(@PathVariable Long[] communityIds)
//    {
//        return toAjax(meterReadingRecordsService.deleteMeterReadingRecordsByCommunityIds(communityIds));
//    }
//}


package com.community.charge.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.community.common.annotation.Log;
import com.community.common.core.controller.BaseController;
import com.community.common.core.domain.AjaxResult;
import com.community.common.enums.BusinessType;
import com.community.charge.domain.MeterReadingRecords;
import com.community.charge.service.IMeterReadingRecordsService;
import com.community.common.utils.poi.ExcelUtil;
import com.community.common.core.page.TableDataInfo;

/**
 * 抄表账单Controller
 *
 * @author ruoyi
 * @date 2025-10-29
 */
@RestController
@RequestMapping("/charge/records")
public class MeterReadingRecordsController extends BaseController {
    @Autowired
    private IMeterReadingRecordsService meterReadingRecordsService;

    /**
     * 查询抄表账单列表
     */
    @PreAuthorize("@ss.hasPermi('charge:records:list')")
    @GetMapping("/list")
    public TableDataInfo list(MeterReadingRecords meterReadingRecords)
    {
        startPage();
        List<MeterReadingRecords> list = meterReadingRecordsService.selectMeterReadingRecordsList(meterReadingRecords);
        return getDataTable(list);
    }

    /**
     * 导出抄表账单列表
     */
    @PreAuthorize("@ss.hasPermi('charge:records:export')")
    @Log(title = "抄表账单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MeterReadingRecords meterReadingRecords)
    {
        List<MeterReadingRecords> list = meterReadingRecordsService.selectMeterReadingRecordsList(meterReadingRecords);
        ExcelUtil<MeterReadingRecords> util = new ExcelUtil<MeterReadingRecords>(MeterReadingRecords.class);
        util.exportExcel(response, list, "抄表账单数据");
    }

    /**
     * 获取抄表账单详细信息
     */
    @PreAuthorize("@ss.hasPermi('charge:records:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(meterReadingRecordsService.selectMeterReadingRecordsById(id));
    }

    /**
     * 新增抄表账单
     */
    @PreAuthorize("@ss.hasPermi('charge:records:add')")
    @Log(title = "抄表账单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MeterReadingRecords meterReadingRecords)
    {
        return toAjax(meterReadingRecordsService.insertMeterReadingRecords(meterReadingRecords));
    }

    /**
     * 修改抄表账单
     */
    @PreAuthorize("@ss.hasPermi('charge:records:edit')")
    @Log(title = "抄表账单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MeterReadingRecords meterReadingRecords)
    {
        return toAjax(meterReadingRecordsService.updateMeterReadingRecords(meterReadingRecords));
    }

    /**
     * 删除抄表账单
     */
    @PreAuthorize("@ss.hasPermi('charge:records:remove')")
    @Log(title = "抄表账单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(meterReadingRecordsService.deleteMeterReadingRecordsByIds(ids));
    }
}